package com.hd.crdao.wrapper;

/**
 * @author Administrator
 * @date 2017/11/20
 */

public class NetWorkLoadHelper<T> {
   /* private OnNetworkListener mOnNetworkListener;

    //private final Class<T> mParameter;


    public NetWorkLoadHelper(String url, HashMap<String, String> hashMap) {
     //   mParameter = getParameter();
        loadNetData(url, hashMap);
    }

    private void loadNetData(String url, HashMap<String, String> hashMap) {

        OkHttpUtils.post().url(url)
                .params(hashMap)
                .build().execute(new CustomCallback<T>() {
            @Override
            public void onError(Call call, Exception e, int id) {
                MyToast.show("网络开了个小差");
            }

            @Override
            public void onResponse(T response, int id) {
               *//* Class<T> entityClass = null;
                Type t = getClass().getGenericSuperclass();
                if (t instanceof ParameterizedType) {
                    Type[] p = ((ParameterizedType) t).getActualTypeArguments();
                    entityClass = (Class<T>) p[0];
                }*//*
                mOnNetworkListener.resolve(response);
            }
        });

    }

    *//*public Class<T> getParameter() {
        Class<T> entityClass = null;
        Type t = getClass().getGenericSuperclass();
        if (t instanceof ParameterizedType) {
            Type[] p = ((ParameterizedType) t).getActualTypeArguments();
            return entityClass = (Class<T>) p[0];
        }
        return entityClass;
    }*//*

    public void addCallBackListener(OnNetworkListener onNetworkListener) {
        if (getClass().getGenericSuperclass() == OnNetworkListener.class.getGenericSuperclass()) {
            if (onNetworkListener != null) {
                this.mOnNetworkListener = onNetworkListener;
            }
        } else {
            new Throwable("两种类型需要一致");
        }

    }


    public interface OnNetworkListener<T1> {

        void resolve(T1 response);
        //   void set(Class<?> mParameter);
    }*/
}
